/*
 *		source/imageviewer/imageviewer.js - Simple image viewer
 */

/* Tegi's Commander - A file manager for Palm WebOS
 * Copyright (C) 2011 Timo Tegtmeier
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

enyo.kind({
	name:	"ImageViewer",
	kind:	"VFlexBox",

	path:	"",

	components:	[{
		name:		"header",
		kind:		"Toolbar",
		className:	"enyo-toolbar-light",
		layoutKind:	"HFlexLayout",
		components:	[{
			name:		"title",
			kind:		"Control",
			className:	"title ellipsis",
			flex:		1
		}]
	}, {
		name:		"viewer",
		kind:		"ImageView",
		flex:		1
	}, {
		name:		"licenseDialog",
		kind:		"LicenseDialog"
	}, {
		name:		"helpDialog",
		kind:		"HelpDialog"
	}, {
		kind:			"AppMenu",
		components:		[{
			kind:		"EditMenu"
		}, {
			caption:	$L("License"),
			onclick:	"openLicense"
		}, {
			caption:	$L("Help"),
			onclick:	"openHelp"
		}]
	}],

	//
	// Menu handling
	//

	openHelp: function() {
		enyo.asyncMethod(this, function() {
			this.$.helpDialog.openAtCenter();
		});
	},

	openLicense: function() {
		enyo.asyncMethod(this, function() {
			this.$.licenseDialog.openAtCenter();
		});
	},

	//
	// Initialization
	//

	create: function() {
		this.inherited(arguments);

		enyo.keyboard.setResizesWindow(false);
		this.path = enyo.windowParams.path;
		this.$.title.setContent($L("ImageViewer") + " - " + this.path);
		this.$.viewer.setImages([this.path]);
	}
});
